//写Cookie
function addCookie(c_name, value, expiredays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
}
//删除cookie
function delCookie(name) {
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval = _getCookie(name);
    if (cval != null)
        document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
}
function _getCookie(name) {
    //获取cookie、
    var arr,
        reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
    if ((arr = document.cookie.match(reg))) return arr[2];
    else return null;
}

//根据参数名称得到地址栏参数的值
function _getQueryPara(name) {
    var query = location.search;
    if (query.length > 1) {
        query = query.substr(1);
        var arr = query.split("&");
        for (var i = 0; i < arr.length; i++) {
            var param = arr[i].split("=");
            if (
                param.length == 2 &&
                name.toLowerCase() == param[0].toLowerCase()
            ) {
                return param[1];
            }
        }
    }
    return "";
}